package com.societyGames.codeAlong.state.codeExercise.model
{
import com.societyGames.codeAlong.state.codeExercise.model.link.IHyperText;
import com.societyGames.codeAlong.state.codeExercise.model.link.ILinkable;

/**
 * Represents a term and its definition.
 * @author ...
 */
public class TermData implements ILinkable, IHyperText
{
  private var _term:String;
  private var _definition:String;

  private static const _termId:String = "term";

  public function TermData(term:String, definition:String)
  {
    this._term = term;
    this._definition = definition;
  }

  public static function fromXml(xml:XML):TermData
  {
    return new TermData(xml.@name, xml.toString());
  }

  public function get term():String
  {
    return this._term;
  }

  public function get definition():String
  {
    return this._definition;
  }

  //ILinkable-->
  public function toLink():String
  {
    return _termId + LibraryData.separator + this._term;
  }

  //<--ILinkable

  //IHyperText-->
  public function toHyperText():String
  {
    return <p><b>{this._term}</b>{this._definition}</p>.toString();
  }

  //<--HyperText
}
}